<?php

	// TITLE: Account_status_type AUTO MODEL
	// FILE: scaffolding/model/account_status_type.php
	// AUTHOR: AUTOGEN
	// CREATED: 2015/04/20 07:49:57
	// DESCRIPTION: 
	// REQUIREMENTS: 

	$createAccountStatusType = function($con, $accountStatusType) {
		$sql = 'INSERT INTO account_status_type (id, title, code, description) VALUES (';
		$sql .= $account_status_type->getId() . ', ';
		$sql .= $account_status_type->getTitle() . ', ';
		$sql .= $account_status_type->getCode() . ', ';
		$sql .= $account_status_type->getDescription() . ')';
		$sql .= ')';
		$result = mysqli_query($con, $sql);
		$id = ($result) ? mysqli_insert_id($con) : $result;
		mysqli_close($con);
		return $id;
	};

	$readAccountStatusType = function($con, $id) {
		$sql = 'SELECT * FROM account_status_type WHERE id = ' . $id;
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$result = mysqli_fetch_array($results);
			$accountStatusType = new AccountStatusType();
			$accountStatusType->setId(result[0]);
			$accountStatusType->setTitle(result[1]);
			$accountStatusType->setCode(result[2]);
			$accountStatusType->setDescription(result[3]);
		} else {
			$accountStatusType = false;
		}
		return $accountStatusType;
	};

	$updateAccountStatusType = function($con, $accountStatusType) {
		$sql = 'UPDATE account_status_type SET ';
		$sql .= 'id = ' . $account_status_type->getId() . ', ';
		$sql .= 'title = ' . $account_status_type->getTitle() . ', ';
		$sql .= 'code = ' . $account_status_type->getCode() . ', ';
		$sql .= 'description = ' . $account_status_type->getDescription() ;
		$sql .= 'WHERE id = ' . id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$deleteAccountStatusType = function($con, $id) {
		$sql = 'DELETE FROM account_status_type WHERE id = ' . $id;
		$result = mysqli_query($con, $sql);
		mysqli_close($con);
		return $result;
	};

	$listAccountStatusType = function($con) {
		$sql = 'SELECT * FROM account_status_type';
		$results = mysqli_query($con, $sql);
		mysqli_close($con);
		if ($results) {
			$accountStatusTypes = array();
			while ($result = mysqli_fetch_array($results)) {
				$accountStatusType = new AccountStatusType();
				$accountStatusType->setId(result[0]);
				$accountStatusType->setTitle(result[1]);
				$accountStatusType->setCode(result[2]);
				$accountStatusType->setDescription(result[3]);
				$accountStatusTypes[] = accountStatusType;
			}// end while
		} else {
			$accountStatusTypes = false;
		}
		return $accountStatusTypes;
	};

